import axios from "axios";
const request = axios.create({
  baseURL: "http://localhost:3008",
});

export default {
  namespaced: true,
  state: {
    title: "info",
  },
  modules: {
    admin: {
      namespaced: true,
      state: {
        title: "info admin",
        users: [],
        auth: "admin auth",
      },
      getters: {
        getTitle: (state) => state.title + "!!",
        myAuth: () => "myAuth admin",
        fullName: () => "jack zhang",
      },
      mutations: {
        SET_USERS: (state, value) => (state.users = value),
        SET_TITLE: (state, value) => (state.title = value),
      },
      actions: {
        getUsers(store) {
          request
            .get("/users")
            .then((res) => {
              // store.state.users = res.data;
              store.commit("SET_USERS", res.data);
            })
            .catch(() => {});
        },
        say(store) {
          console.log(store.state.title);
        },
      },
    },
  },
};
